<?php  
class DB_CONNECT { 

	// construtor
	function __construct() { 
		// conectar com o bd
		$this->connect(); 
	} 
	
	function __destruct() { 
		// fechar conexao bd
		$this->close();
	} 
	
	/** 
	 * funcao conectar com db
	 */ 
	 function connect() { 
		// importar variaveis de conecxao db
		require __DIR__ . '/config.php'; 
		
		// conn com mysql db
		$con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error()); 
		
		// selecionando db
		$db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error()); 
		
		return $con; 
	}

	function close() { 
		// fechar db
		mysql_close(); 
	} 
}
?>